

from app.libs.error_code import Success
from app.libs.redprint import Redprint
from app.models.user import UserModel
from app.validates.user import UserForm

api = Redprint('login')


@api.route('', methods=['POST'])
def login():
    form = UserForm().validate_and_api()
    token = UserModel().login(form.username.data, form.password.data)
    return Success(data=token)
